//
//  MD5.m
//  TradeCircle
//
//  Created by SHERMAN on 2017/7/16.
//  Copyright © 2017年 sherman. All rights reserved.
//

#import "MD5.h"
#import <CommonCrypto/CommonDigest.h>


@implementation MD5

+ (NSString *)md5:(NSString *)input
{
    if (!input) {
        return @"";
    }
    const char *cStr = [input UTF8String];
    unsigned char digest[CC_MD5_DIGEST_LENGTH];
    CC_MD5( cStr, (CC_LONG)strlen(cStr), digest );
    NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
    for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
        [output appendFormat:@"%02x", digest[i]];
    }
    return output;
}

@end
